package service

import (
	"zzxq/repository/userrepository"
	"zzxq/tools"
)

type Sms struct{}

//发送短信
func (p *Sms) SLoginCode(phone string) bool {
	//生成验证码
	code := tools.GenValidateCode(6)

	// log.Println("phone code", code)
	//发送短信逻辑

	//设置缓存
	redisLogin := userrepository.RedisLogin{}
	redisLogin.SetLoginCode(phone, code)

	return true
}

//获取登录验证码
func (p *Sms) GLoginCode(phone string) string {
	redisLogin := userrepository.RedisLogin{}
	code := redisLogin.GetLoginCode(phone)

	return code
}
